package com.upb.webserver.dao.mapper;

import com.upb.webserver.dao.entity.TbHost;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import com.upb.webserver.dao.entity.TbHostExample;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

public interface TbHostMapper {

    @Select({ "select", "ip", "from tb_host", "where id = #{hostId,jdbcType=INTEGER}" })
    @Results({ @Result(column = "ip", property = "ip", jdbcType = JdbcType.VARCHAR) })
    String selectIpByPrimaryKey(@Param("hostId") Integer hostId);

    @Select({ "select","id, org_id, company_id, ip, ssh_user, ssh_port, root_dir, min_port, max_port, ", "docker_port, already_used_port_max, status, create_from_platform, create_by, ", "gmt_create, gmt_modified", "from tb_host", "where ip = #{ip,jdbcType=VARCHAR}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "ip", property = "ip", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_user", property = "sshUser", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_port", property = "sshPort", jdbcType = JdbcType.INTEGER), @Result(column = "root_dir", property = "rootDir", jdbcType = JdbcType.VARCHAR), @Result(column = "min_port", property = "minPort", jdbcType = JdbcType.INTEGER), @Result(column = "max_port", property = "maxPort", jdbcType = JdbcType.INTEGER), @Result(column = "docker_port", property = "dockerPort", jdbcType = JdbcType.INTEGER), @Result(column = "already_used_port_max", property = "alreadyUsedPortMax", jdbcType = JdbcType.INTEGER), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_from_platform", property = "createFromPlatform", jdbcType = JdbcType.TINYINT), @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    List<TbHost> selectHostByIp(@Param("ip") String ip);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbHostSqlProvider.class, method = "countByExample")
    long countByExample(TbHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbHostSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_host", "where id = #{id,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_host (org_id, company_id, ", "ip, ssh_user, ssh_port, ", "root_dir, min_port, ", "max_port, docker_port, ", "already_used_port_max, status, ", "create_from_platform, create_by, ", "gmt_create, gmt_modified)", "values (#{orgId,jdbcType=INTEGER}, #{companyId,jdbcType=INTEGER}, ", "#{ip,jdbcType=VARCHAR}, #{sshUser,jdbcType=VARCHAR}, #{sshPort,jdbcType=INTEGER}, ", "#{rootDir,jdbcType=VARCHAR}, #{minPort,jdbcType=INTEGER}, ", "#{maxPort,jdbcType=INTEGER}, #{dockerPort,jdbcType=INTEGER}, ", "#{alreadyUsedPortMax,jdbcType=INTEGER}, #{status,jdbcType=TINYINT}, ", "#{createFromPlatform,jdbcType=TINYINT}, #{createBy,jdbcType=INTEGER}, ", "#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})" })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(TbHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbHostSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insertSelective(TbHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbHostSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "ip", property = "ip", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_user", property = "sshUser", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_port", property = "sshPort", jdbcType = JdbcType.INTEGER), @Result(column = "root_dir", property = "rootDir", jdbcType = JdbcType.VARCHAR), @Result(column = "min_port", property = "minPort", jdbcType = JdbcType.INTEGER), @Result(column = "max_port", property = "maxPort", jdbcType = JdbcType.INTEGER), @Result(column = "docker_port", property = "dockerPort", jdbcType = JdbcType.INTEGER), @Result(column = "already_used_port_max", property = "alreadyUsedPortMax", jdbcType = JdbcType.INTEGER), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_from_platform", property = "createFromPlatform", jdbcType = JdbcType.TINYINT), @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    List<TbHost> selectByExample(TbHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @Select({ "select", "id, org_id, company_id, ip, ssh_user, ssh_port, root_dir, min_port, max_port, ", "docker_port, already_used_port_max, status, create_from_platform, create_by, ", "gmt_create, gmt_modified", "from tb_host", "where id = #{id,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "ip", property = "ip", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_user", property = "sshUser", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_port", property = "sshPort", jdbcType = JdbcType.INTEGER), @Result(column = "root_dir", property = "rootDir", jdbcType = JdbcType.VARCHAR), @Result(column = "min_port", property = "minPort", jdbcType = JdbcType.INTEGER), @Result(column = "max_port", property = "maxPort", jdbcType = JdbcType.INTEGER), @Result(column = "docker_port", property = "dockerPort", jdbcType = JdbcType.INTEGER), @Result(column = "already_used_port_max", property = "alreadyUsedPortMax", jdbcType = JdbcType.INTEGER), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_from_platform", property = "createFromPlatform", jdbcType = JdbcType.TINYINT), @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    TbHost selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbHostSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbHost record, @Param("example") TbHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbHostSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbHost record, @Param("example") TbHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbHostSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @Update({ "update tb_host", "set org_id = #{orgId,jdbcType=INTEGER},", "company_id = #{companyId,jdbcType=INTEGER},", "ip = #{ip,jdbcType=VARCHAR},", "ssh_user = #{sshUser,jdbcType=VARCHAR},", "ssh_port = #{sshPort,jdbcType=INTEGER},", "root_dir = #{rootDir,jdbcType=VARCHAR},", "min_port = #{minPort,jdbcType=INTEGER},", "max_port = #{maxPort,jdbcType=INTEGER},", "docker_port = #{dockerPort,jdbcType=INTEGER},", "already_used_port_max = #{alreadyUsedPortMax,jdbcType=INTEGER},", "status = #{status,jdbcType=TINYINT},", "create_from_platform = #{createFromPlatform,jdbcType=TINYINT},", "create_by = #{createBy,jdbcType=INTEGER},", "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},", "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({ "<script>", "insert into tb_host (org_id, ", "company_id, ip, ", "ssh_user, ssh_port, ", "root_dir, min_port, ", "max_port, docker_port, ", "already_used_port_max, status, ", "create_from_platform, create_by, ", "gmt_create, gmt_modified)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.orgId,jdbcType=INTEGER}, ", "#{detail.companyId,jdbcType=INTEGER}, #{detail.ip,jdbcType=VARCHAR}, ", "#{detail.sshUser,jdbcType=VARCHAR}, #{detail.sshPort,jdbcType=INTEGER}, ", "#{detail.rootDir,jdbcType=VARCHAR}, #{detail.minPort,jdbcType=INTEGER}, ", "#{detail.maxPort,jdbcType=INTEGER}, #{detail.dockerPort,jdbcType=INTEGER}, ", "#{detail.alreadyUsedPortMax,jdbcType=INTEGER}, #{detail.status,jdbcType=TINYINT}, ", "#{detail.createFromPlatform,jdbcType=TINYINT}, #{detail.createBy,jdbcType=INTEGER}, ", "#{detail.gmtCreate,jdbcType=TIMESTAMP}, #{detail.gmtModified,jdbcType=TIMESTAMP})</foreach></script>" })
    int batchInsert(List<TbHost> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_host
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbHostSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "ip", property = "ip", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_user", property = "sshUser", jdbcType = JdbcType.VARCHAR), @Result(column = "ssh_port", property = "sshPort", jdbcType = JdbcType.INTEGER), @Result(column = "root_dir", property = "rootDir", jdbcType = JdbcType.VARCHAR), @Result(column = "min_port", property = "minPort", jdbcType = JdbcType.INTEGER), @Result(column = "max_port", property = "maxPort", jdbcType = JdbcType.INTEGER), @Result(column = "docker_port", property = "dockerPort", jdbcType = JdbcType.INTEGER), @Result(column = "already_used_port_max", property = "alreadyUsedPortMax", jdbcType = JdbcType.INTEGER), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_from_platform", property = "createFromPlatform", jdbcType = JdbcType.TINYINT), @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    Optional<TbHost> getOneByExample(TbHostExample example);
}
